package icu.cocoon.system.controller;


import icu.cocoon.dao.base.BaseController;
import icu.cocoon.dao.base.Resp;
import icu.cocoon.system.entity.Org;
import icu.cocoon.system.service.OrgService;
import icu.cocoon.util.TreeNode;
import icu.cocoon.util.TreeUtil;
import java.util.List;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Cocoon
 * @since 2020-06-11
 */
@RestController
@RequestMapping("/system/org")
public class OrgController extends BaseController<Org, OrgService> {


  @GetMapping("/tree")
  public Resp<TreeNode> getTree() {
    List<Org> treeList = getService().list();
    TreeNode treeNode = TreeUtil.getInitTree(treeList);
    return Resp.success(treeNode);
  }
}

